package com.wjs.gulimall.gulimallorder.controller;

import com.wjs.gulimall.gulimallorder.entity.OrderOperateHistoryEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class TestController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/send")
    public String sendMsg(){
        for(int i=0;i<10;i++){
            OrderOperateHistoryEntity entity=new OrderOperateHistoryEntity();
            entity.setId((long)i);
            entity.setCreateTime(new Date());
            entity.setNote("wjs"+i);
            entity.setOrderStatus(i);
            entity.setOperateMan("wzw");
            rabbitTemplate.convertAndSend("my-direct-exchange","wjs",entity);
        }
        return "ok";
    }
}
